package uav;

import javax.inject.Inject;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Component;

@Component
public class Uav {
	@Value("ABC")
	private String type;
//	@Autowired
//	@Qualifier("simple")
	@Inject
	private IMissile missile;
	
	

//	public IMissile getMissile() {
//		return missile;
//	}
//
//
//
//	public void setMissile(IMissile missile) {
//		this.missile = missile;
//	}

	

	public Uav(IMissile missile) {
		super();
		this.missile = missile;
	}



	@Override
	public String toString() {
		return "Uav [type=" + type + "]";
	}



	public Uav() {
		super();
	}


	public void attack(){
		missile.fire();
	}

	public static void main(String[] args) {
		ConfigurableApplicationContext ctx =
	              new ClassPathXmlApplicationContext("uav/uav2.xml");
		Uav uav1 = (Uav)ctx.getBean("uav");
		uav1.attack();
		System.out.println(uav1);
		
			ctx.close();
	}

}
